#pragma once
#include"Common.hpp"

/*一个session应该有的成员：
                        1.用户的id
                        2.session的id--方便管理
                        3.定时器
                        4.用户的状态*/
enum class SESSION_STATU
{
    LOGINED,
    DIS_LOGIN
};//session状态
class Session
{
private:
    LL _uid;
    LL _session_id;
    WebSocketServer::timer_ptr _timer;
    SESSION_STATU _statu;
public:
    Session(LL session_id) : _session_id(session_id),_statu(SESSION_STATU::DIS_LOGIN)
    {
        LOG(DEBUG,"创建了一个Session,Id = %lu\n",_session_id);
    }
    ~Session()
    {
        LOG(DEBUG,"销毁了一个Session,Id = %lu\n",_session_id);
    }
    void SetUid(LL uid)
    {
        _uid = uid;
    }
    void SetSessionId(LL session_id)
    {
        _session_id = session_id;
    }
    //设置已登录状态
    void SetLoginStatu()
    {
        _statu = SESSION_STATU::LOGINED;
    }
    //设置未登录状态
    void SetDisLoginStatu()
    {
        _statu = SESSION_STATU::LOGINED;
    }
    //判断是都是登陆状态
    bool IsLogin()
    {
        return _statu == SESSION_STATU::LOGINED;
    }
    LL Uid()
    {
        return _uid;
    }
    LL SessionId()
    {
        return _session_id;
    }
    void SetTimer(const WebSocketServer::timer_ptr& timer)
    {
        _timer = timer;
    }
    WebSocketServer::timer_ptr& Timer()
    {
        return _timer;
    }
};
